// ProtectedRoute.js
import { Navigate } from 'react-router-dom';
import { useAuth } from '../hooks';

function Guard({role, children }) {
  const {isLogin,user} =useAuth();

  if (!isLogin()) {
    return <Navigate to="/login" replace />; 
  }

  if(role && role!==user.role){
    return;
  }

  return children;
}

export default Guard;